<?php
/**
 * ClassName:excel导入工具
 * @auditor:leijunxiang
 * @time 2025/4/8 8:55
 */

namespace app\tool\util;

use PhpOffice\PhpSpreadsheet\IOFactory;

class ExcelInput
{
    public function excelLoad($filePath)
    {
        // 加载文件
        $spreadsheet = IOFactory::load($filePath);
        $worksheet = $spreadsheet->getActiveSheet();

        // 获取所有工作表
        $worksheets = $spreadsheet->getAllSheets();

        // 获取最高行和列
        $highestRow = $worksheet->getHighestRow();
        $highestColumn = $worksheet->getHighestColumn();
//
//        foreach ($worksheets as $index => $worksheet){
//            echo "查看表格".$index."\n";
//        }
        $cellValue = $worksheet->getCell("B5")->getValue();
//        // 遍历每一行
//        for ($row = 1; $row <= $highestRow; ++$row) {
//            // 遍历每一列
//            for ($col = 'A'; $col <= $highestColumn; ++$col) {
//                // 获取单元格的值
//                $cellValue = $worksheet->getCell($col . $row)->getValue();
//                var_dump("查看值",gettype($cellValue)."_".$cellValue."\n");
////                echo "行 $row, 列 $col: $cellValue\n";
//            }
//        }
    }
}